{template header}
<style type="text/css">
     td, th {
        min-width: 40px; max-width: 300px; overflow:hidden; text-overflow:ellipsis ;
         overflow: hidden; text-align: center;
}
   td:nth-child(1),
     th:nth-child(1) { max-width: 100px;  text-align: left;}
     td:nth-child(3),
     th:nth-child(3) { max-width: 80px; text-align: center; }
     td:nth-child(4),
     th:nth-child(4) { max-width: 30px; text-align: center; }
     td:nth-child(14),
     th:nth-child(14) { max-width: 20px; text-align: center; }
     td:nth-child(6),
     th:nth-child(6) { max-width: 60px; text-align: center; }
     td:nth-child(7),
     th:nth-child(7) { max-width: 60px; text-align: center; }
     


     .table-striped th,
     .table-striped td  { text-align: center;}
    
</style>
<h4 style="padding-left:10px;;">
    <span>搜索</span>
    <i class="icon-search"></i>
</h4>
<form class="form-horizontal" method="post" action="" id="custom_data">
    <div class="control-group search-group" style="margin:0px;padding:0px">
        <label class="control-label">ID或关键词：</label>
        <div class="controls">
          <input type="text" placeholder="设置后其他选项忽略" name="name" value="{$search['name']}">
        </div>
    </div>
    <div class="control-group search-group" style="margin:0px;padding:0px">
        <label class="control-label">品类：</label>
        <div class="controls">
            <select name="cat" class="catId" data-value="$search['cat']">
            </select>
        </div>
    </div>
    <div class="control-group search-group" style="margin:0px;padding:0px">
        <label class="control-label" >品牌：</label>
        <div class="controls">
            <select name="brand" class="brand" data-value="$search['brand']">
            </select>
        </div>
    </div>
    <div class="control-group search-group" style="display:none">
        <label class="control-label">性别：</label>
        <div class="controls">
            <select name="gender">
                <option value="">请选择</option>
                <option {if $search['gender'] == 1}selected="selected"{/if} value="1">男</option>
                <option {if $search['gender'] == 2}selected="selected"{/if} value="2">女</option>
                <option {if $search['gender'] == 3}selected="selected"{/if} value="3">男女同款</option>
            </select>
        </div>
    </div>
    
    <div class="control-group search-group" style="display:none">
        <label class="control-label">足型：</label>
        <div class="controls">
            <select name="footType">
                <option value="">请选择</option>
                {loop $shoeAttr['footType'] $k $footType}
                <option {if $search['footType'] == $k} selected="selected" {/if} value="{$k}">$footType</option>
                {/loop}
            </select>
        </div>
    </div>
    <div class="control-group search-group" style="display:none">
        <label class="control-label">适合足类：</label>
        <div class="controls">
            <select name="footType">
                <option value="">请选择</option>
                {loop $shoeAttr['footCircle'] $k $footCircle}
                <option {if $search['footCircle'] == $k} selected="selected" {/if} value="{$k}">$footCircle</option>
                {/loop}
            </select>
        </div>
    </div>
    <div class="control-group search-group" style="display:none">
        <label class="control-label">功能：</label>
        <div class="controls">
            <select name="funcTag">
                <option value="">请选择</option>
                {loop $shoeAttr['funcTag'] $k $funcTag}
                <option {if $search['funcTag'] == $k} selected="selected" {/if} value="{$k}">$funcTag</option>
                {/loop}
            </select>
        </div>
    </div>
    <div class="control-group search-group" style="display:none">
        <label class="control-label">描述：</label>
        <div class="controls">
            <select name="nullDesc">
                <option value="-1">请选择</option>
                <option {if $search['nullDesc'] == 1}selected="selected"{/if} value="1">空</option>
                <option {if $search['nullDesc'] == 0}selected="selected"{/if} value="0">不空</option>
            </select>
        </div>
    </div>
    <div class="control-group search-group" style="margin:0px;padding:0px">
        <label class="control-label">有效：</label>
        <div class="controls">
            <select name="isShow">
                <option value="-1">请选择</option>
                <option {if $search['isShow'] == 1}selected="selected"{/if} value="1">是</option>
                <option {if $search['isShow'] == 0}selected="selected"{/if} value="0">否</option>
            </select>
        </div>
    </div>
     <div class="control-group search-group" style="display:none">
        <label class="control-label" >购买链接：</label>
        <div class="controls">
            <select name="shopUrl">
                <option value="-1">请选择</option>
                <option {if $search['shopUrl'] == 1}selected="selected"{/if} value="1">有</option>
                <option {if $search['shopUrl'] == 0}selected="selected"{/if} value="0">无</option>
            </select>
        </div>
    </div>
    <div class="control-group search-group">
        <div class="controls">
            <input type="hidden" value="search" name="s">
            <button class="btn" type="submit">提交</button>　
            <button class="btn" type="reset">重置</button>
        </div>
    </div>
</form>
<div class="bs-docs-example" style="clear:both; padding-top: 30px;">
    <table class="table table-striped">
        <thead>
            <tr >
                <th>ID</th>
                <th >名称</th>
                <th >图片</th>
                <th>品牌</th>
                <th>类别</th>
                <th>性别</th>
                <th>售价</th>
                <th width=40>收藏</th>
                <th width=40>热度</th>
                <th>状态</th>
                <th style="display:none">添加时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {loop $gearList $k $v}
            <tr id="{$v['gearId']}">
                <td>{$v['gearId']}</td>
                <td>{$v['name']}</td>
                <td>
                    {loop $v['images'] $kk $img}
                        <img style="max-width:30px;max-height:30px;" src="{$img}">
                    {/loop}
                </td>
                <td>{if $v['brand']} {$v['brand']['brandName']} {/if}</td>
                <td>{if $v['cat']} {$v['cat']['catName']} {/if}</td>
                <td>{if $v['gender'] == 1}男{else}女{/if}</td>
                <td>￥{$v['price']}</td>
                <td>$v['viewCounts']</td>
                <td>$v['likes']</td>
                <td>{if $v['isShow'] == 1}是 {else} <span style="color:red">否</span>{/if}</td> 
                <td style="display:none">{eval echo date("Y-m-d H:i:s", $v['addTime'])}</td>
                <td>
                    <a class="btn btn-edit" href="?c=admin&a=gearInfo&gearId=$v['gearId']">编辑</a>
                     <a style="display:none" class="btn btn-edit" href="?c=admin&a=addGearComment&gearId=$v['gearId']">加评</a>&nbsp;
                     <a class="btn btn-edit" href="?c=admin&a=gearcommentList&gearId={$v['gearId']}">查看评论</a>&nbsp;
                      <a style="display:none" class="btn btn-edit addset" data-id="{$v['gearId']}">添加到集合</a>&nbsp;
                </td>
            </tr>
            {/loop}
        </tbody>
    </table>
</div>
<div class="pagination">
    <ul>
        {$pageStr}
    </ul>
</div>
<script type="text/javascript">
var gid;
$('.addset').on('click',function(){
    $('tbody select').hide();
    gid=$(this).attr('data-id');
   $.ajax({
        url:'/admingear/addtosetbefore',
        data:{gid:gid},
        dataType:'json',
        type:'post',
        success:function(res){
            var size=1
            if(res){
                html='<option>请选择</option>'
                for(k in res){
                    html+='<option value="'+res[k]["setId"]+'">'+res[k]["setName"]+'</opntion>';
                    size++;
                }                    
                $('#_'+gid).html(html)
                $('#_'+gid).attr('size',5);
                //.html(html)
                $('#_'+gid).show();                   
                
            }
        }
   })
})
 $('tbody select').on('change',function(){
    var sid=$(this).val();
     $.ajax({
        url:'/admingear/addtoset',
        data:{gid:gid,sid:sid},
        dataType:'json',
        type:'post',
        success:function(res){
            alert(res.msg);
            $('tbody select').hide();
        }
    })
})  

$('.addadd').on('click',function(){
    var tid=$(this).attr('data-id');
    var tnum=$(this).attr('data-num');
    var ttype=$(this).attr('data-type');
    tnum=tnum+prompt('请输入'+tnum);
    $.ajax({
        url:'/admingear/gearaddsub',
        data:{id:tid,num:tnum,type:ttype},
        type:'post',
        success:function(res){
            $('#'+tid).find('.'+ttype).html(res)
        }
    })
})  

</script>
<script src="/static/js/jquery.cxselect.min.js"></script>
<script>
    $('#custom_data').cxSelect({
  selects: ['catId', 'brand'],
  jsonName: 'name',
  jsonValue: 'value',
  jsonSub: 'sub',
  data:  $rootCatJson
});
</script>
{template footer}
